package cn.com.template.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.com.dal.dataobject.VerifyDO;
import cn.com.service.VerifyService;
import cn.com.service.impl.VerifyServiceImpl;
import cn.com.support.SessionKeeper;
import cn.com.support.context.UserContext;

@Controller
public class Index {

	Logger logger = LoggerFactory.getLogger(Index.class);
	
	@Autowired
	private VerifyService verifyService;

	@RequestMapping("/" )
	public ModelAndView root(HttpServletResponse response,
			HttpServletRequest request) {
		ModelAndView mav = new ModelAndView("index");
		mav.addObject("user", request.getSession().getAttribute(SessionKeeper.USER_DETAIL));
		return mav;
	}

	@RequestMapping("/welcome")
	public ModelAndView welcome() {
		ModelAndView mav=new ModelAndView("welcome");
		mav.addObject("needVerifyTotalCount", verifyService.selectNeedVerifyTotalCount(UserContext.getUsername()));
		HashMap<Object,Object> params=new HashMap<Object,Object>();
		params.put("userName",UserContext.getUsername());
		params.put("status", VerifyDO.STATUS_DOING);
		mav.addObject("verifingTotalCount", verifyService.selectVerifingTotalCount(params));
		params.put("status", VerifyDO.STATUS_REJECT);
		mav.addObject("rejectTotalCount", verifyService.selectVerifingTotalCount(params));
		return mav;
	}

}
